<?php

namespace app\common\model\mall\order;

use think\Hook;
use think\Model;

class Goods extends Model
{
    // 表名
    protected $name = 'mall_order_goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [

    ];

    public function getGoodsimgAttr($value, $data)
    {
        if(!$value) $value = \app\common\model\mall\goods\Goods::getFieldById($data["goods_id"],"goodsimg");
        $mallcdn = config("mall.mallcdn");
        if($mallcdn && !stristr($value,$mallcdn))
            return $mallcdn ? $mallcdn.$value : cdnurl($value);
        else
            return cdnurl($value);
    }

    public function getGoodsnameAttr($value, $data)
    {
        if(!$value) $value = \app\common\model\mall\goods\Goods::getFieldById($data["goods_id"],"goodsname");
        return $value;
    }
}
